package com.sn.pw.controller;

import com.sn.pw.result.Result;
import com.sn.pw.service.OrderService;
import com.sn.pw.vo.req.BiddingReq;
import com.sn.pw.vo.req.IdReq;
import com.sn.pw.vo.req.ShippingOrderNumberReq;
import com.sn.pw.vo.resp.CompanyOrderResp;
import com.sn.pw.vo.resp.OrderResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/logisticsInfo")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@Api(value = "订单相关-Api",tags = "订单相关-Api")
public class OrderController {

    private final OrderService service;

//    @PostMapping("/getBiddingList")
//    @ApiOperation(value = "获取竞价中的订单")
//    public Result<List<OrderResp>> getBiddingList(@RequestBody BiddingReq biddingReq) {
//        return Result.success(service.getBiddingList(biddingReq));
//    }
//
//    @PostMapping("/getSuccessList")
//    @ApiOperation(value = "获取竞价成功的订单")
//    public Result<List<OrderResp>> getSuccessList(@RequestBody BiddingReq biddingReq) {
//        return Result.success(service.getSuccessList(biddingReq));
//    }
//
//    @PostMapping("/getFailedList")
//    @ApiOperation(value = "获取竞价失败的订单")
//    public Result<List<OrderResp>> getFailedList(@RequestBody BiddingReq biddingReq) {
//        return Result.success(service.getFailedList(biddingReq));
//    }

    @PostMapping("/getFailedList")
    @ApiOperation(value = "获取竞价的订单")
    public Result<List<OrderResp>> getList(@RequestBody BiddingReq biddingReq) {
        return Result.success(service.addBidder(biddingReq));
    }


    @PostMapping("/getDeliveredOrderByUserId")
    @ApiOperation(value = "获取用户已签收的订单信息")
    public Result<List<OrderResp>> getDeliveredOrderByUserId(@Valid @RequestBody IdReq idReq) {
        return Result.success(service.getDeliveredOrderByUserId(idReq.getId()));
    }

    @PostMapping("/getWaitingOrderByUserId")
    @ApiOperation(value = "获取用户代发货的订单信息")
    public Result<List<OrderResp>> getWaitingOrderByUserId(@Valid @RequestBody IdReq idReq) {
        return Result.success(service.getWaitingOrderByUserId(idReq.getId()));
    }

    @PostMapping("/getTransitOrderByUserId")
    @ApiOperation(value = "获取用户运输中的订单信息")
    public Result<List<OrderResp>> getTransitOrderByUserId(@Valid @RequestBody IdReq idReq) {
        return Result.success(service.getTransitOrderByUserId(idReq.getId()));
    }

    @PostMapping("/getArrivedOrderByUserId")
    @ApiOperation(value = "获取用户已送达的订单信息")
    public Result<List<OrderResp>> getArrivedOrderByUserId(@Valid @RequestBody IdReq idReq) {
        return Result.success(service.getArrivedOrderByUserId(idReq.getId()));
    }

    @PostMapping("/getEvaluationOrderByUserId")
    @ApiOperation(value = "获取用户已评价的订单信息")
    public Result<List<OrderResp>> getEvaluationOrderByUserId(@Valid @RequestBody IdReq idReq) {
        return Result.success(service.getEvaluationOrderByUserId(idReq.getId()));
    }

    @PostMapping("/getTopFiveDataByUserId")
    @ApiOperation(value = "展示用户的五条竞价订单")
    public Result<List<OrderResp>> getTopFiveDataByUserId(@Valid @RequestBody IdReq idReq) {
        return Result.success(service.getTopFiveDataByUserId(idReq.getId()));
    }

    @PostMapping("/getMainOrderInfoByShippingOrderNumber")
    @ApiOperation(value = "根据出单号获取物流订单信息")
    public Result<CompanyOrderResp> getMainOrderInfoByShippingOrderNumber(@Valid @RequestBody ShippingOrderNumberReq shippingOrderNumber) {
        return Result.success(service.getMainOrderInfoByShippingOrderNumber(shippingOrderNumber.getShippingOrderNumber()));
    }

}
